//! UDP协议

#![no_std]

mod address;
mod socket;

use address::SocketAddr;
use fixed_queue::LinearMap;
use socket::UdpSocket;
use unmp_protocol::*;

/// 协议ID
pub const PROTOCOL_ID: u8 = 17;

pub struct ProtocolUdp {
    ch: DataChannel,
    sockets: LinearMap<u16, (), 4>,
}
impl ProtocolUdp {
    pub fn new(distributor: &mut Distributor) -> Option<ProtocolUdp> {
        let ch = distributor.register(PROTOCOL_ID)?;
        Some(Self {
            ch,
            sockets: LinearMap::new(),
        })
    }
    pub fn bind(&mut self, addr: SocketAddr) -> UdpSocket {
        UdpSocket { local: addr }
    }
    pub async fn run(self) -> ! {
        todo!()
    }
}
